package com.gjs.intranet.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gjs.common.manager.response.RspBody;
import com.gjs.common.pojo.dto.request.PageQuery;
import com.gjs.common.pojo.dto.response.ListPageRsp;
import com.gjs.intranet.pojo.dto.LibraryProjectQueryDTO;
import com.gjs.intranet.pojo.entity.LibraryProject;
import com.gjs.intranet.service.ILibraryProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 项目表 前端控制器
 * </p>
 *
 * @author JC_Ho
 * @since 2022-04-11
 */
@RestController
@Slf4j
@Api(tags = "图书项目接口")
@RequiredArgsConstructor
@RequestMapping("/library/project")
public class LibraryProjectController {
    private final ILibraryProjectService projectService;

    @GetMapping("/list")
    @ApiOperation("列表")
    public RspBody<ListPageRsp<LibraryProject>> list(LibraryProjectQueryDTO queryDTO, PageQuery pageQuery){
        IPage<LibraryProject> iPage = projectService.page(pageQuery.buildPage(),projectService.buildWrapper(queryDTO));
        return RspBody.success(ListPageRsp.of(iPage));
    }

    @GetMapping("/detail")
    @ApiOperation("详情")
    public RspBody<LibraryProject> detail(Long id){
        LibraryProject book = projectService.getById(id);
        Assert.notNull(book,"找不到该项目");
        return RspBody.success(book);
    }

    @PostMapping("/add")
    @ApiOperation("添加")
    public RspBody add(){
        return RspBody.success();
    }

    @PostMapping("/update")
    @ApiOperation("更新")
    public RspBody update(){
        return RspBody.success();
    }
}
